<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/center/lib/layui-v2.5.5/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/center/css/public.css}" media="all">
	<script th:src="@{/center/lib/layui-v2.5.5/layui.js}" charset="utf-8"></script>
	<script th:inline="none">
	    layui.use(['form', 'table'], function () {
	        var $ = layui.jquery,
	            form = layui.form,
	            table = layui.table;
	
	
	        var tableIns = null;
	
	        // 监听搜索操作
	        //多条件查询
	        form.on('submit(data-search-btn)', function (data) {
	            var jsonstr = JSON.stringify(data.field);
	            tableIns = table.render({
	                elem: '#currentTableId',
	                url: '/center/showAllForumAdminApply',
	                method: "post",
	                contentType: 'application/json;charset=utf-8',
	
	                initSort: {
	                    field: 'username',
	                    type: 'desc'
	                },
	                toolbar: '#toolbarDemo',
	                defaultToolbar: ['filter', 'exports', 'print', {
	                    title: '提示',
	                    layEvent: 'LAYTABLE_TIPS',
	                    icon: 'layui-icon-tips'
	                }],
	                cols: [
	                    [
	                        {
	                            field: 'username',
	                            width: 150,
	                            title: '用户名',
	                            sort: true
	                        },
	                        {
	                            field: 'forumname',
	                            width: 200,
	                            title: '社区名',
	                            sort: true
	                        },
	                        {
	                            field: 'content',
	                            width: 200,
	                            title: '备注信息',
	                            sort: true
	                        },
	                        {
	                            field: 'userid',
	                            width: 100,
	                            title: '用户ID',
	                        },
	                        {
	                            field: 'forumid',
	                            width: 100,
	                            title: '社区ID',
	                        },
	                        {
	                            field: 'id',
	                            width: 100,
	                            title: '申请ID',
	                        },
	
	                        {
	                            title: '审核',
	                            minWidth: 80,
	                            toolbar: '#currentTableBar',
	                            align: "center"
	                        }
	                    ]
	                ],
	                page: false,
	                skin: 'row'
	            });
	
	            return false;
	        });
	
	        //监听审批
	        table.on('tool(currentTableFilter)', function (obj) {
	            var data = obj.data;
	            // var passjson = JSON.stringify({'userid':data.userid,'forumid':data.forumid,'id':data.id});
	            var rejectjson=JSON.stringify({'id':data.id});
	            if (obj.event === 'pass') { //监听通过操作
	                layer.confirm('是否确定通过审核?', function (index) {
	                    $.ajax({
	                        url: '/center/passForumAdmin',
	                        contentType: 'application/json;charset=utf-8',
	                        method: 'POST',
	                        data:JSON.stringify( {'userid':data.userid,'forumid':data.forumid,'id':data.id}),
	                        success: function (res) {
	                            console.log("前端接收到的回调:" + res);
	                            tableIns.reload();
	                            layer.alert(res.msg);
	
	                        }
	                    });
	
	                    layer.close(index);
	                });
	                return false;
	            } else if (obj.event === 'reject') { //监听拒绝操作
	                layer.confirm('是否确定拒绝?', function (index) {
	                    $.ajax({
	                        url: '/center/rejectForumAdmin',
	                        contentType: 'application/json;charset=utf-8',
	                        method: 'POST',
	                        data: rejectjson,
	                        success: function (res) {
	                            tableIns.reload();
	                            layer.alert(res.msg);
	
	                        }
	                    });
	
	                    layer.close(index);
	                });
	            }
	        });
	
	
	    });
	</script>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>查询待审核的论坛管理员申请</legend>
            <div style="margin: 10px 10px 10px 10px">
                <div class="layui-inline">
                    <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i
                            class="layui-icon"></i>
                        查询
                    </button>
                </div>
            </div>
            </form>
        </fieldset>
    </div>



    <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

    <script type="text/html" id="currentTableBar">
        <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="pass">通过</a>
        <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="reject">不通过</a>

    </script>

</div>
</div>
</body>
</html>
